/**
 * @format
 */

import {AppRegistry} from 'react-native';
import App from './App';
import App01 from './App01';
import {name as appName} from './app.json';

import { Database } from '@nozbe/watermelondb'
import SQLiteAdapter from '@nozbe/watermelondb/adapters/sqlite'

import schema from './model/schema'
import migrations from './model/migrations'

// index.js
import Post from './model/Post'

// const database = new Database({
//   // ...
//   modelClasses: [Post],
// })



import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux';
import { RootState, AppDispatch } from './redux/store';

// Use throughout your app instead of plain `useDispatch` and `useSelector`
export const useAppDispatch = () => useDispatch<AppDispatch>{};
export const useAppSelector = useSelector;


// First, create the adapter to the underlying database:
const adapter = new SQLiteAdapter({
    schema,
    // (You might want to comment it out for development purposes -- see Migrations documentation)
    migrations,
    // (optional database name or file system path)
    // dbName: 'myapp',
    // (recommended option, should work flawlessly out of the box on iOS. On Android,
    // additional installation steps have to be taken - disable if you run into issues...)
    jsi: false, /* Platform.OS === 'ios' */
    // (optional, but you should implement this method)
    onSetUpError: error => {
      // Database failed to load -- offer the user to reload the app or log out
    }
  })
  
  // Then, make a Watermelon database from it!
  export const database = new Database({
    adapter,
    modelClasses: [
      Post, // ⬅️ You'll add Models to Watermelon here
    ],
  })


AppRegistry.registerComponent(appName, () => App);
AppRegistry.registerComponent('abc', () => App01);
